package com.tc.quartz.support.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.tc.quartz.frame.base.BaseController;
import com.tc.quartz.frame.common.ParamUtil;
import com.tc.quartz.support.bean.JobRunLogBean;
import com.tc.quartz.support.service.IJobRunLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 日志管理
 * @author yongjin.ye
 *
 */
@RequestMapping(value = "/jobRunLog")
@Controller
public class JobRunLogController extends BaseController {

	@Autowired
	private IJobRunLogService jobRunLogService;
	
	/**
	 * 进入list页面 
	 */
	@RequestMapping(value="/list", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
	public String list() {
		return "forward:/jsp/jobRunLog/list.jsp";
	}
	

	/**
	 * 进入list query页面 
	 */
	@RequestMapping(value="/list", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String listQuery(JobRunLogBean logBean) {
		int page = ParamUtil.getInt(this.getRequest(), "page", 1);
		int pagesize = ParamUtil.getInt(this.getRequest(), "pagesize", 10);
		PageInfo<JobRunLogBean> pageInfo = this.jobRunLogService.getPageList(logBean, page, pagesize);
		
		return JSON.toJSONString(pageInfo);
	}
	

	/**
	 * 查询详情，此方法暂不使用
	 */
	@RequestMapping(value="/detail", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
	@ResponseBody
	@Deprecated
	public String detail(String id) {
		JobRunLogBean runLogBean = this.jobRunLogService.getById(id);
		return JSON.toJSONString(runLogBean);
	}
	
	
}
